﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ABC.Google;
using System.Windows.Forms;


namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Count() == 0)
            {
                Console.WriteLine("Invalid Arguments...");
                Console.Read();
            }
            else
            {
                string databaseSchema = null;
                #region UPDATEWORKORDERAGE
                if (args[0] == "UPDATEWORKORDERAGE")
                {
                    try
                    {

                    }
                    catch (Exception ex)
                    {

                    }
                }
                #endregion
                #region SETGEOCODE
                //Execute this brance if user wants to get GEOCODE and set it to the database f
                if (args[0] == "SETGEOCODE")
                {
                    try
                    {
                        databaseSchema = args[1];
                        string fullAddress = null;

                        for (int i = 3; i < args.Length; i++)
                        {
                            fullAddress += args[i];
                          
                            if (i < args.Length - 1)
                            {
                                fullAddress += "+";
                            }
                        }

                        fullAddress = fullAddress.Replace('#', ' ');   //google maps cannot have a #
                    
                        ABC.Google.GeoCodes.setAddressGeoCode(fullAddress, Convert.ToInt32(args[2]));
                     
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Inner Exception: " + ex.InnerException + " Stack Trace: " + ex.StackTrace + " Message: " + ex.Message);
                    }
                }
                #endregion
                #region GETTRIPDISTANCES
                else if (args[0] == "GETTRIPDISTANCES")
                {
                    //need to find code which will get distance between each 
                    //address lisetd in the Trip list. 
                    //code will probably read from a table of trip addresses, then get the 
                    //distance between each one storing it back in the database. 

                }
                #endregion

            }
        }


        static public void displayMenu()
        {

        }
    }
}
